//
//  BiIndexBorrowViewController.m
//  TrunkIndustryManageSystem
//
//  Created by 李璐西 on 15-4-27.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "BiIndexBorrowViewController.h"
#import "BiBorrowListViewController.h"
#import "BiReturnListViewController.h"

@interface BiIndexBorrowViewController ()

@end

@implementation BiIndexBorrowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    

    NSDictionary * imageDic = [NSDictionary dictionaryWithObjectsAndKeys:@"common/icon_liebiao",@"bycarcheck",
                               @"common/icon_liebiao",@"returncheck",nil];
    
    
    NSDictionary * titleDic = [NSDictionary dictionaryWithObjectsAndKeys:@"借车审批",@"bycarcheck",
                               @"归还审批",@"returncheck",nil];
    
    
    
    NSMutableArray * imagearr = [NSMutableArray array];
    NSMutableArray * titlearr = [NSMutableArray array];
    NSArray * saleArr = [BiUserEntity sharedInstance].permissionDic[@"zhengchejieche"];
    
    for (int i =0 ; i < saleArr.count; i++) {
        NSString * borrowStr = saleArr[i];
        
        [imagearr addObject:imageDic[borrowStr]];
        
        [titlearr addObject:titleDic[borrowStr]];
    }
    
    
    [self refreshTable:titlearr imageArr:titlearr title:@"整车借车"];
    
}


#pragma -mark UitabeViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    UITableViewCell * cell  = [tableView cellForRowAtIndexPath:indexPath];
    
    UILabel * tltlelab = (UILabel *)[cell viewWithTag:2];
    
    if (tltlelab.text.hash == @"借车审批".hash) {
        
        BiBorrowListViewController *viewCtrl = [[BiBorrowListViewController alloc]init];
        [self.navigationController pushViewController:viewCtrl animated:YES];;
    }
    
    else  if (tltlelab.text.hash == @"归还审批".hash) {
        
        BiReturnListViewController *viewCtrl = [[BiReturnListViewController alloc] init];
        [self.navigationController pushViewController:viewCtrl animated:YES];
    }
    
}


@end
